/*
 * @Author: Jimmy
 * @LastModifiedBy: Jimmy
 * @Date: 2024-12-14 13:41:52
 * @LastEditTime: 2025-02-25 20:56:41
 * @FilePath: /monitor_belt/src/views/history/column.tsx
 */
import DictionaryLabel from "@/components/dictionary_label";
import { alarmStatus, AlarmStatusEnum, alarmTypes } from "@/utils/dictionary";
import { Button, Flex, Image } from "antd";
import { TAction } from "./index.type";

export const columns = (deal:Function) => [
  {
    title: "设备名称",
    dataIndex: "device",
    width:120,
    ellipsis: true,
  },
  {
    title: "运输线",
    dataIndex: "conveyor",
    width:120,
    ellipsis: true,
  },
  {
    title: "预警类型",
    dataIndex: "alarm_type",
    ellipsis: true,
    width:120,
    render: (_text: any) => (
      <DictionaryLabel list={[...alarmTypes]} label={"label"} value={_text} />
    ),
  },
  {
    title: "状态",
    dataIndex: "state",
    ellipsis: true,
    width:100,
    render: (_text: any) => (
      <DictionaryLabel list={[...alarmStatus]} isDot label={"label"} value={_text} />
    ),
  },
  {
    title: "消息",
    dataIndex: "msg",
    ellipsis: true,
  },
  {
    title: "发生时间",
    dataIndex: "create_time",
    ellipsis: true,
  },
  {
    title: "更新时间",
    dataIndex: "update_time",
    ellipsis: true,
  },
  {
    title: "关联图片",
    dataIndex: "rel_img_url",
    width: 120,
    render: (_text: string) => {
      return _text ? <Image width={70} src={_text} /> : null;
    },
  },
  {
    title: "操作",
    dataIndex: "action",
    width: 100,
    render: (_text: any, _row: any, _index: number) => (
      <Flex>
        {_row.state == AlarmStatusEnum.UNCONFIRM ? (
          <Button size="small" type="link" danger onClick={()=>deal(_row,TAction.RELEASE)}>
            解除预警
          </Button>
        ) : null}
      </Flex>
    ),
  },
];
